import { ApiCall } from "tsrpc";
import { ReqTransferPoin, ResTransferPoin } from "../../../shared/master/word/PtlTransferPoin";
import { player } from "../../../model/fight/body/player";
import { template } from "../../../shared/master/MsgAction";

export default async function (call: ApiCall<ReqTransferPoin, ResTransferPoin>) {
    call.succ({})
    let user = call.req._player as player;



    if (user.get_battle()) {
        user.sendMsg(template.default, '战斗中无法传送')
        return;
    }
    let res = user.check_wallet(0, 0, [{ id: 'prop-3', v: 1 }], false, '传送消耗',true);
    if (!res.state) {
        return;
    }
    let moveX = call.req.x;
    let moveY = call.req.y;

    let _cell = user.getPosition();
    let _word = _cell.getWord();
    let tag_cell = _word.getCell(moveX, moveY);
    if (!tag_cell) {
        user.sendMsg(template.default, '传送失败,目标点不可传送')
        return;
    }
    user.setPosition(tag_cell);
    user.callApi('word/Position', {});

}